﻿/*
   Author: Tomer Paz
   BOGO.com
   2009
*/

/* Title Pane template */

package monopoly.views {
	import fl.controls.Label;
	import fl.containers.ScrollPane;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.events.Event;
	import monopoly.IFS.GLOBALS;
	
	public class TitlePane extends ScrollPane 
		{
		protected var _label:Label;
		
		protected var _defaultWidth = 200;
		protected var _defaultHeight = GLOBALS.DEFAULT_TITLE_HEIGHT;
		
		public function TitlePane(Title:String)
			{
			with (this)
				{
				setSize(_defaultWidth, _defaultHeight);
				alpha = 1;
				//opaqueBackground = GLOBALS.DEFAULT_TITLE_COLOR;
				}

			setupLabel(Title);
			}

		public function set Text(Title:String):void
			{
			this._label.text = Title;
			}
			
		public function remove( ):void
			{
			removeChild(_label);
			}
			
		protected function onPaneResize(e:Event):void
			{
			_label.drawNow();
			}
			
		protected function setupLabel(Title:String):void
			{
			_label = new Label();
			
			_label.textField.autoSize = TextFieldAutoSize.CENTER;
			_label.visible = true;
			
			addChild(_label);
            _label.move(width/3, 2);
			_label.text = Title;
			}
		}
}